function setupJudgeExportGrid() {
    $("#judgeSearch").jqGrid({
        url : 'getJudgeSearchtList.action',
        datatype : "local",
        colNames : [ '序号','评委类别', '姓名', '性别', '籍贯', '出生日期', '最高学历','单位', '职位', '手机', '邮箱地址', '调用次数','','' ],
        colModel : [ { name : 'no', index : 'no', width : 25, sortable: false },
                     { name : 'categoryId', index : 'categoryId', width : 60},
                     { name : 'name', index : 'name', width : 60 },
                     { name : 'isMale', index : 'isMale', width : 30 },
                     { name : 'hometown', index : 'hometown', width : 60 },
                     { name : 'birthday', index : 'birthday', width : 80 },
                     { name : 'topEducation', index : 'topEducation', width : 60 },
                     { name : 'workUnit', index : 'workUnit', width : 80 },
                     { name : 'post', index : 'post', width : 60 },
                     { name : 'cellPhone', index : 'cellPhone', width : 80 },
                     { name : 'mailAddress', index : 'mailAddress', width : 90 },
                     { name : 'callTimes', index : 'callTimes', width : 60 },
                     { name : 'callHistory', index : 'callHistory', width : 65, sortable: false },
                     { name : 'judgeDetail', index : 'judgeDetail', width : 65, sortable: false }
                   ],
        rowNum : 10,
        height : 'auto',
        rowList : [ 10, 20, 30 ],
        pager : '#pager',
        sortname : 'id',
        viewrecords : true,
        sortorder : "desc",
        caption : "评委信息一览",
        gridComplete : function() {
            var ids = $('#judgeSearch').jqGrid('getDataIDs');
            for (var i = 0; i < ids.length; i++) {
                var id = ids[i];
                $('#judgeSearch').jqGrid('setRowData', id, {
                    callHistory : "<button class='gridBtn' onclick='toHistory(" + id + ");'>调用履历</button>",
                    judgeDetail : "<button class='gridBtn' onclick='toDetail(" + id + ");'>评委详细</button>"
                });
            }
        },
        multiselect : false,
        loadError : dealError
    });
    $("#judgeSearch").jqGrid('navGrid', '#pager', {
        edit : false,
        add : false,
        del : false
    });
}

function setupJudgeExportToolbar() {
    $("#search").button({
        icons : {
            primary : "ui-icon-search"
        }
    }).click(function() {
        $("#detail").dialog("open");
    });

    $("#keywordMatch").button({
        icons : {
            primary : "ui-icon-search"
        }
    }).click(function() {
        $("#keywordDetail").dialog("open");
    });

    $("#export").button({
        icons : {
            primary: "ui-icon-copy"
        }
    }).click(function() {
        $("#judgeDetail").submit();
    });
}

function setupJudgeExportDialog() {
    $("#detail").dialog({
        autoOpen : false,
        show : "slide",
        height : 600,
        width : 600,
        modal : true,
        buttons : {
            检索 : function() {
                var judgeSearch = {
                    'judgeSearch.idNo' : $("#idNo").val(),
                    'judgeSearch.name' : $("#name").val(),
                    'judgeSearch.sex' : $("#sex").val(),
                    'judgeSearch.birthdayFrom' : $("#birthdayFrom").val(),
                    'judgeSearch.birthdayTo' : $("#birthdayTo").val(),
                    'judgeSearch.graduatedFrom' : $("#graduatedFrom").val(),
                    'judgeSearch.topEducation' : $("#topEducation").val(),
                    'judgeSearch.educationType' : $("#educationType").val(),
                    'judgeSearch.subject' : $("#subject").val(),
                    'judgeSearch.workUnit' : $("#workUnit").val(),
                    'judgeSearch.title' : $("#title").val(),
                    'judgeSearch.post' : $("#post").val(),
                    'judgeSearch.skillsCert' : $("#skillsCert").val(),
                    'judgeSearch.workPhone' : $("#workPhone").val(),
                    'judgeSearch.cellPhone' : $("#cellPhone").val(),
                    'judgeSearch.imAddress' : $("#imAddress").val(),
                    'judgeSearch.mailAddress' : $("#mailAddress").val(),
                    'judgeSearch.workAddress' : $("#workAddress").val(),
                    'judgeSearch.address' : $("#address").val(),
                    'judgeSearch.trainExperience' : $("#trainExperience").val(),
                    'judgeSearch.workExperience' : $("#workExperience").val(),
                    'judgeSearch.hometown' : $("#hometown").val(),
                    'judgeSearch.homePhone' : $("#homePhone").val(),
                    'judgeSearch.speciality' : $("#speciality").val(),
                    'judgeSearch.remark' : $("#remark").val()
                };
                var postData = $("#judgeSearch").jqGrid("getGridParam", "postData");
                $.extend(postData, judgeSearch);
                $("#judgeSearch").jqGrid("setGridParam", {
                    search: true,
                    datatype : "json"
                }).trigger("reloadGrid", [{page:1}]);

                $(this).dialog("close");
                return false;
            },
            取消 : function() {
                $(this).dialog("close");
                return false;
            }
        },
        close : function() {
            ;
        }
    });

    $('#keywordDetail').dialog({
        autoOpen : false,
        show : "slide",
        height : 200,
        width : 250,
        modal : true,
        buttons : {
            筛选 : function() {
                var sexCodeArray = getSexMatchCode($("#keyword").val());
                var educationCodeArray = getEducationMatchCode($("#keyword").val());
                var educationTypeCodeArray = getEducationTypeMatchCode($("#keyword").val());
                var judgeSearch = {
                    'judgeSearch.idNo' : $('#keyword').val(),
                    'judgeSearch.name' : $('#keyword').val(),
                    'judgeSearch.sex' : -1,
                    'judgeSearch.sexCodes' : sexCodeArray.join(),
                    'judgeSearch.birthdayFrom' : '',
                    'judgeSearch.birthdayTo' : '',
                    'judgeSearch.graduatedFrom' : $('#keyword').val(),
                    'judgeSearch.topEducation' : -1,
                    'judgeSearch.topEducationCodes' : educationCodeArray.join(),
                    'judgeSearch.educationType' : -1,
                    'judgeSearch.educationTypeCodes' : educationTypeCodeArray.join(),
                    'judgeSearch.subject' : $('#keyword').val(),
                    'judgeSearch.workUnit' : $('#keyword').val(),
                    'judgeSearch.title' : $('#keyword').val(),
                    'judgeSearch.post' : $('#keyword').val(),
                    'judgeSearch.skillsCert' : $('#keyword').val(),
                    'judgeSearch.workPhone' : $('#keyword').val(),
                    'judgeSearch.cellPhone' : $('#keyword').val(),
                    'judgeSearch.imAddress' : $('#keyword').val(),
                    'judgeSearch.mailAddress' : $('#keyword').val(),
                    'judgeSearch.workAddress' : $('#keyword').val(),
                    'judgeSearch.address' : $('#keyword').val(),
                    'judgeSearch.trainExperience' : $('#keyword').val(),
                    'judgeSearch.workExperience' : $('#keyword').val(),
                    'judgeSearch.hometown' : $('#keyword').val(),
                    'judgeSearch.homePhone' : $('#keyword').val(),
                    'judgeSearch.speciality' : $('#keyword').val(),
                    'judgeSearch.remark' : $('#keyword').val(),
                    'judgeSearch.isOr' : true
                };
                var postData = $("#judgeSearch").jqGrid("getGridParam", "postData");
                $.extend(postData, judgeSearch);
                $("#judgeSearch").jqGrid("setGridParam", {
                    search: true,
                    datatype : "json"
                }).trigger("reloadGrid", [{page:1}]);

                $(this).dialog("close");
                return false;
            },
            解除筛选 : function() {
                var judgeSearch = {
                    'judgeSearch.idNo' : '',
                    'judgeSearch.name' : '',
                    'judgeSearch.sex' : -1,
                    'judgeSearch.sexCodes' : '',
                    'judgeSearch.birthdayFrom' : '',
                    'judgeSearch.birthdayTo' : '',
                    'judgeSearch.graduatedFrom' : '',
                    'judgeSearch.topEducation' : -1,
                    'judgeSearch.topEducationCodes' : '',
                    'judgeSearch.educationType' : -1,
                    'judgeSearch.educationTypeCodes' : '',
                    'judgeSearch.subject' : '',
                    'judgeSearch.workUnit' : '',
                    'judgeSearch.title' : '',
                    'judgeSearch.post' : '',
                    'judgeSearch.skillsCert' : '',
                    'judgeSearch.workPhone' : '',
                    'judgeSearch.cellPhone' : '',
                    'judgeSearch.imAddress' : '',
                    'judgeSearch.mailAddress' : '',
                    'judgeSearch.workAddress' : '',
                    'judgeSearch.address' : '',
                    'judgeSearch.trainExperience' : '',
                    'judgeSearch.workExperience' : '',
                    'judgeSearch.hometown' : '',
                    'judgeSearch.homePhone' : '',
                    'judgeSearch.speciality' : '',
                    'judgeSearch.remark' : '',
                    'judgeSearch.isOr' : true
                };
                var postData = $("#judgeSearch").jqGrid("getGridParam", "postData");
                $.extend(postData, judgeSearch);
                $("#judgeSearch").jqGrid("setGridParam", {
                    search: true,
                    datatype : "json"
                }).trigger("reloadGrid", [{page:1}]);

                $(this).dialog("close");
                return false;
            },
            取消 : function() {
                $(this).dialog("close");
                return false;
            }
        },
        close : function() {
            ;
        }
    });
}

function toHistory(id) {
    $('#judgeId').val(id);
    $('#rForm').attr("action", "showJudgeCallHistory.action");
    $('#rForm').submit();
}

function toDetail(id) {
    $('#judgeId').val(id);
    $('#rForm').attr("action", "showJudgeDetail.action");
    $('#rForm').submit();
}
